import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:kq_flutter_core_widget/utils/text_filed_utils.dart';
import 'package:kq_flutter_widgets/widgets/listener/kq_vertical_drag_gesture_listener.dart';


///解决键盘不弹关闭的问题
class KqScaffold extends Scaffold {
  KqScaffold({
    Widget? body,
    super.key,
    super.extendBody,
    super.extendBodyBehindAppBar,
    super.appBar,
    super.floatingActionButton,
    super.floatingActionButtonLocation,
    super.floatingActionButtonAnimator,
    super.persistentFooterButtons,
    super.persistentFooterAlignment,
    super.drawer,
    super.onDrawerChanged,
    super.endDrawer,
    super.onEndDrawerChanged,
    super.drawerScrimColor,
    super.backgroundColor,
    super.bottomNavigationBar,
    super.bottomSheet,
    super.resizeToAvoidBottomInset,
    super.primary,
    super.drawerDragStartBehavior,
    super.drawerEdgeDragWidth,
    super.drawerEnableOpenDragGesture,
    super.endDrawerEnableOpenDragGesture,
    super.restorationId,
  }) : super(
          body: !kIsWeb && Platform.isIOS
              ? Builder(builder: (context) {
                  return KqVerticalDragGestureListener(
                    child: GestureDetector(
                      behavior: HitTestBehavior.translucent,
                      onTap: () {
                        TextFiledUtil.hideKeyboard(context);
                      },
                      onVerticalDragUpdate: (v) {
                        TextFiledUtil.hideKeyboard(context);
                      },
                      child: body,
                    ),
                    onVerticalDragUpdate: (v) {
                      TextFiledUtil.hideKeyboard(context);
                    },
                  );
                })
              : body,
        );
}
